
/*
*Released on 28th June 2008.
*Any violations can be reported at paritosh@wikiocean.net
*What is treated as violations can be found at www.wikiocean.net/ppl1-voilations*
******************************************************************************
* The contents of this file are subject to POOL Public License 1.0 and later.
* POOL Public License is based on Affero GPL v3 and additional conditions.
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the Affero GPL v3 License at http://www.gnu.org/licenses/agpl.html
* You may obtain a copy of the POOL Public License 1.0 or later at www.wikiocean.net/license/ppl.html
* Software distributed under POOL Public License 1.0 is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Initial Developer of the Original Code is Paritosh Pungaliya (C) 2008. All Rights Reserved.
******************************************************************************
* Objective of the additional terms (license)
* 1) Is to extend the software freedom to freedom to work.
* 2) To ensure that knowledge is free from monopoly of agencies.
* 3) To avoid a situation where big corporate or investor can buy out free software groups and companies and then start milking the communities built around it.
* (this trend can be seen how the freedom is curtailed in companies that get Venture Capital funding.)
******************************************************************************
*/

package  smsBean;


import java.util.Hashtable;
import java.util.Vector;

import logger.PoolLogger;

import pool.process.Process;

import control.RequestParameter;
import utility.CapitalChar;
import dbmanager.DBManager;
import dbmanager.GetIdName;




public abstract class SubSmsBean implements SmsBean
{
	
	String message;	
	String request;
	String process;
	String userid;
	String id = "";
	StringBuffer sbrDTB = new StringBuffer();
	GetIdName gid; 
	
	RequestParameter reqParam;
	
	/*public void setUserid(String userid) 
	{
		this.userid = userid;
	}	
	
	public void setMessage(String message) 
	{
		this.message = message;
	}
	
	public void setProcess(String process) 
	{
		this.process = process;
	}
	
	public void setRequest(String request) 
	{
		this.request = request;
	}*/
	
	PoolLogger pl;
	
	public SubSmsBean() {
		// logger
		pl = (PoolLogger) PoolLogger.getLogger(this.getClass().getName());
	}
	
	public void initPool()
	{
		gid = new GetIdName();
	}		
	
	public void setRequestParameter(RequestParameter reqParam) 
	{
		this.reqParam = reqParam;
		
		//version = reqParam.getVersion();
		//password = reqParam.getPassword();
		//productName = reqParam.getProductName();
		
		request= reqParam.getRequest();
		process = reqParam.getProcess();
		message = reqParam.getMessage();		
		userid= reqParam.getUsername();
	}
	
	 
	/**
	 * processSms() method which is going to create a specific process object like Add, Mod, etc. 
	 * & calls setSmsObject() of a specific process
	 * */
	@SuppressWarnings("unchecked")
	public Hashtable<Object,Object>  processSms()
	{
		Hashtable<Object, Object> hashM = new Hashtable<Object, Object>();
		try 
		{			
			Class C = Class.forName("pool.process."+CapitalChar.makeFirstCharCapital(process));
			Process p = (Process)C.newInstance();
			
			hashM.putAll(p.setSmsObject(this,request));
		}
		catch (ClassNotFoundException e) 
		{
			hashM.put("Error", process+" : this process is not found");
			pl.info("Error :: "+process+" : this process is not found");
			pl.debug("Error :: "+process+" : this process is not found");
			pl.warn("Error :: "+process+" : this process is not found");
			pl.fatal("Error :: "+process+" : this process is not found");
			pl.error("Error :: "+process+" : this process is not found");
			pl.trace("Error :: "+process+" : this process is not found");
		}
		catch (InstantiationException e) 
		{
			e.printStackTrace();
		}
		catch (Exception e) 
		{
			e.printStackTrace();
			hashM.put("Error", process+" : Error in input");
			pl.info("Error :: "+process+" : Error in input");
			pl.debug("Error :: "+process+" : Error in input");
			pl.warn("Error :: "+process+" : Error in input");
			pl.fatal("Error :: "+process+" : Error in input");
			pl.error("Error :: "+process+" : Error in input");
			pl.trace("Error :: "+process+" : Error in input");
		}
		return hashM;
	}
	
	
	public String getId() {
		return id;
	}
	
	public RequestParameter getReqParam() {
		return reqParam;
	}
	
	public String getProcess() {
		return process;
	}
	
	public Hashtable<Object,Object> getHashtable(){
		return new Hashtable<Object, Object>();
	}
	
	public Vector<Object> getTransDetailsVector(){
		return new Vector<Object>();
	}
	
	public Hashtable<Object,Object> getOldHashtable() {
		return new Hashtable<Object, Object>();
	}
	
	public Hashtable<Object,Object> getNewHashtable() {
		return new Hashtable<Object, Object>();
	}
	
	public Vector<Object> getOldPropertyVector() {		
		return new Vector<Object>();
	}
	
	public Vector<Object> getNewPropertyVector() {
		return new Vector<Object>();		
	}
	
	public Hashtable<Object,Object> getPropertyViewHashtable() {
		return new Hashtable<Object, Object>();
	}
	
	public Hashtable<Object,Object> getTransDetailsViewHashtable() {
		return new Hashtable<Object, Object>();	
	}
	public Hashtable<Object, Object> initializeToDel()
	{
		return  new Hashtable<Object, Object>(); 
		
	}
	
	public StringBuffer generatesms(StringBuffer strbuffer)
	{
		SmsProperty_details smspl = new SmsProperty_details();
		smspl.setRequestParameter(reqParam);
		smspl.initPool();		
		return smspl.generatesms(strbuffer);
	}
}
